package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.Channel;
import com.rockcent.mall.lib.domain.enumclass.ChannelClientType;
import com.rockcent.mall.lib.domain.enumclass.ChannelStatus;
import com.rockcent.mall.lib.dto.ChannelDto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

/**
 * Created by oyhk on 14-6-22.
 */
@Repository
public interface ChannelRepository extends JpaRepository<Channel, Long>, JpaSpecificationExecutor,ChannelRepositoryCustom {

    Channel findByMerchantIdAndName(Long merchantId, String name);

    Channel findByIdAndIsDelete(Long channelId, Whether no);

    Channel findBySalesCodeAndIsDelete(String salesCode,Whether isDelete);

    Channel findByIdAndIsDeleteAndChannelStatus(Long channelId, Whether no, ChannelStatus using);

    int countByMallIdAndChannelStatusAndIsDelete(Long mallId, ChannelStatus using, Whether no);

    Channel findByIdAndMerchantId(Long channelId, Long id);

    Channel findByIdAndMerchantIdAndIsDelete(Long channelId, Long id, Whether no);

    Channel findTop1ByAppFlagAndIsDeleteAndChannelStatus(Whether yes, Whether no, ChannelStatus using);

    Channel findTop1ByAppFlagAndAppDefaultAndIsDeleteAndChannelStatus(Whether whether,Whether yes, Whether no, ChannelStatus using);

    Channel findByIdAndChannelStatusAndChannelClientType(Long channelId, ChannelStatus channelStatus, ChannelClientType channelClientType);
}
